<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>ECharts-series-系列图-itemStyle</title>
  </head>
  <body>
    <div id="main" style="height: 400px"></div>
    <script src="../libs/echarts-5.3.3.js"></script>
    <script>
      window.onload = function () {
        let myChart = echarts.init(document.getElementById("main"));
        let option = {
          backgroundColor: "rgba(255, 0, 0, 0.1)",
          grid: {
            show: true,
            backgroundColor: "rgba(0, 255, 0, 0.1)",
          },

          xAxis: {
            data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
          },
          yAxis: {},
          series: [
            {
              name: "产品销量柱形图",
              type: "bar",

              // 系列图形的样式
              itemStyle: {
                color: "green", // 颜色
                borderColor: "orange", // 边框颜色
                borderWidth: 4, // 边框宽度
                opacity: 0.4, // 透明度
              },

              // 方式三(推荐)
              data: [
                {
                  value: 5,
                  name: "衬衫", // 数据项名称, 比如pie系列 tooltip 需要用到
                  // label ....
                  itemStyle: {
                    // 系列图形的样式
                    color: "red",
                  },
                },
                {
                  value: 20,
                  name: "羊毛衫",
                  itemStyle: {
                    // 系列图形的样式
                    color: "orange",
                  },
                },
                {
                  value: 36,
                  name: "雪纺衫",
                  itemStyle: {
                    // 系列图形的样式
                    color: "pink",
                  },
                },
                {
                  value: 10,
                  name: "裤子",
                },
                {
                  value: 10,
                  name: "高跟鞋",
                },
                {
                  value: 20,
                  name: "袜子",
                },
              ],
            },
          ],
        };
        myChart.setOption(option);
      };
    </script>
  </body>
</html>
